package com.tianze.tzkf.function.home;


import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.tianze.tzkf.R;
import com.tianze.tzkf.bean.GetVersionBean;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by Zcyang on 2018/12/29.
 */
@SuppressLint("ValidFragment")
public class HomeExitDialog extends DialogFragment {

    @BindView(R.id.rl_exit_dialog_Bottom)
    RelativeLayout rl_exit_dialog_Bottom;
    @BindView(R.id.tv_exit_dialog_Back)
    TextView tv_exit_dialog_Back;

    Unbinder unbinder;

    HomeActivity homeActivity;


    @SuppressLint("ValidFragment")
    public HomeExitDialog(HomeActivity homeActivity) {
        this.homeActivity = homeActivity;
    }

    public static HomeExitDialog newInstance(HomeActivity homeActivity) {

        Bundle args = new Bundle();
        HomeExitDialog fragment = new HomeExitDialog(homeActivity);
        fragment.setArguments(args);
        return fragment;
    }


    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.dialog_fragment_exit, container);
        unbinder = ButterKnife.bind(this, view);
        getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        return view;

    }



    @Override
    public void onStart() {
        super.onStart();
    }


    @Override
    public void onResume() {
        super.onResume();
    }




    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick({R.id.rl_exit_dialog_Bottom, R.id.tv_exit_dialog_Back})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.rl_exit_dialog_Bottom:
                dismiss();
                homeActivity.exit();
                break;
            case R.id.tv_exit_dialog_Back:
                dismiss();
                break;
        }
    }
}
